import { list, exportList, getInfoById, addInfo, putInfoById, delInfoById } from '@/api/apartment/apartmentRoom'

const data = {
    state: {
        list: []
    },

    mutations: {
        SET_list: (state, list) => {
            state.list = list
        },
    },

    actions: {
        // 获取列表
        async getTable({ commit }, params) {
            const { rows, code, total } = await list(params);
            commit("SET_list", rows)
            return { rows, code, total }
        },

        async exportList({ commit }, params) {
            const { data, code } = await exportList(params);
            return { data, code }
        },

        async getInfoById({ commit }, params) {
            const { data, code } = await getInfoById(params);
            return { data, code }
        },

        async addInfo({ commit }, params) {
            const { data, code } = await addInfo(params);
            return { data, code }
        },

        async putInfoById({ commit }, params) {
            const { data, code } = await putInfoById(params);
            return { data, code }
        },

        async delInfoById({ commit }, params) {
            const { data, code } = await delInfoById(params);
            return { data, code }
        },
    },
    namespaced: true,
}

export default data
